<template>
	<el-tag disable-transitions :size="size" :type="tagType">{{ tagName }}</el-tag>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
	name: 'dictTag',
	props: {
		dict: String,
		data: String,
		size: {
			type: String,
			default: 'small'
		}
	},
	computed: {
		...mapGetters(['dictEnums']),
		dictData() {
			return this.dictEnums[this.dict].find((item) => item.value === this.data);
		},
		tagType() {
			let text = '';
			switch(this.data) {
			case '1':
				text = '';
				break;
			case '2':
				text = 'success';
				break;
			case '3':
				text = 'warning';
				break;
			case '4':
				text = 'info';
				break;
			}
			return text;
		},
		tagName() {
			return !this.dictData ? '--' : this.dictData.msg;
		}
	}
};
</script>

<style scoped></style>